// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   QuestionAction.java

package com.iphaeton.lms.action.exam;

import com.iphaeton.common.helper.Pagination;
import com.iphaeton.common.helper.UserSession;
import com.iphaeton.exception.BusinessException;
import com.iphaeton.lms.business.certificate.ICertificateService;
import com.iphaeton.lms.business.exam.IQuestionService;
import com.iphaeton.lms.business.organize.*;
import com.iphaeton.lms.pojo.certificate.Certificate;
import com.iphaeton.lms.pojo.course.Course;
import com.iphaeton.lms.pojo.exam.*;
import com.iphaeton.lms.pojo.organize.Group;
import com.iphaeton.lms.pojo.organize.Organize;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import org.apache.log4j.Logger;
import org.apache.struts.action.*;

// Referenced classes of package com.iphaeton.lms.action.exam:
//            QuestionBizSupportAction

public class QuestionAction extends QuestionBizSupportAction
{

    public QuestionAction()
    {
    }

    public ActionForward addQuestionPrepare(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String sort_id = (String)request.getAttribute("sort_id");
        List sortList = new LinkedList();
        List hardList = new LinkedList();
        List stationList = new LinkedList();
        List dutyList = new LinkedList();
        try
        {
            sortList = question.queryQuestionSort();
            if(sort_id == null || "".equals(sort_id))
            {
                for(Iterator it = sortList.iterator(); it.hasNext();)
                {
                    QuestionSort qs = (QuestionSort)it.next();
                    if(qs.getName().equals("\u5355\u9879\u9009\u62E9\u9898"))
                        sort_id = qs.getId();
                }

            }
            hardList = question.queryQuestionHard();
            stationList = group.getGroupList("g", "");
            dutyList = group.getGroupList("z", "");
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            return mapping.findForward("failure");
        }
        request.setAttribute("sortList", sortList);
        request.setAttribute("hardList", hardList);
        request.setAttribute("stationList", stationList);
        request.setAttribute("dutyList", dutyList);
        request.setAttribute("sort_id", sort_id);
        return mapping.findForward("question_create");
    }

    public ActionForward addQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        daf = (DynaActionForm)form;
        Calendar cal = Calendar.getInstance();
        java.util.Date time = cal.getTime();
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String currentTime = df.format(time);
        String hard_id = (String)daf.get("hard_id");
        String sort_id = (String)daf.get("sort_id");
        String course_id = (String)daf.get("course_id");
        String station_id = (String)daf.get("station_id");
        String duty_id = (String)daf.get("duty_id");
        String question_content = (String)daf.get("question_content");
        String prepare_answer = "";
        QuestionSort sort = null;
        Question q = new Question();
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String user_id = userSession.getId();
            sort = question.findQuestionSortById(sort_id);
            if(sort.getName().equals("\u5355\u9879\u9009\u62E9\u9898") || sort.getName().equals("\u591A\u9879\u9009\u62E9\u9898"))
            {
                int prepare_count = Integer.parseInt(request.getParameter("prepare_count"));
                for(int i = 1; i <= prepare_count; i++)
                    prepare_answer = prepare_answer + request.getParameter("prepare_answer_" + i) + ";;;";

                q.setPrepareAnswer(prepare_answer);
            }
            String standard_answer = (String)daf.get("standard_answer");
            q.setQuestionContent(question_content);
            q.setStandardAnswer(standard_answer);
            q.setSortId(sort_id);
            q.setHardId(hard_id);
            q.setUserId(user_id);
            q.setDutyId(duty_id);
            q.setStationId(station_id);
            q.setCreateTime(currentTime);
            q.setState(new Integer(1));
            if(!"".equals(course_id) && course_id != null)
                q.setCourseId(course_id);
            q = question.persistent(q);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("sort_id", sort_id);
        return mapping.findForward("addQuestionPrepare");
    }

    public ActionForward removeQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        String question_id[] = id.split(";");
        try
        {
            for(int i = 0; i < question_id.length; i++)
                question.removeQuestion(question_id[i]);

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        return mapping.findForward("questionList");
    }

    public ActionForward questionManage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String user_id = request.getParameter("user_id");
        String sort_id = request.getParameter("sort_id");
        List sortList = new LinkedList();
        List sort = null;
        List list = null;
        try
        {
            if("all".equals(user_id))
            {
                user_id = "";
            } else
            {
                UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
                user_id = userSession.getId();
            }
            if(sort_id == null || "".equals(sort_id))
            {
                sort_id = "";
                sortList = question.queryQuestionSort();
            } else
            {
                sortList.add(question.findQuestionSortById(sort_id));
            }
            sort = question.queryQuestionSort();
            String hard_id = request.getParameter("hard_id");
            if(hard_id == null)
                hard_id = "";
            String course_id = request.getParameter("course_id");
            if(course_id == null)
                course_id = "";
            String station_id = request.getParameter("station_id");
            if(station_id == null)
                station_id = "";
            String duty_id = request.getParameter("duty_id");
            if(duty_id == null)
                duty_id = "";
            list = question.queryQuestion(sort_id, hard_id, course_id, user_id, station_id, duty_id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("sort", sort);
        request.setAttribute("sortList", sortList);
        request.setAttribute("list", list);
        return mapping.findForward("question_list");
    }

    public ActionForward questionDetail(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        Question q = null;
        try
        {
            q = question.findQuestionById(id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        if(q.getCourse() != null)
            request.setAttribute("question_course", q.getCourse().getName());
        else
            request.setAttribute("question_course", "");
        if(!q.getStationId().equals("") && q.getStationId() != null)
            request.setAttribute("question_station", q.getStation().getName());
        else
            request.setAttribute("question_station", "");
        if(!q.getDutyId().equals("") && q.getDutyId() != null)
            request.setAttribute("question_duty", q.getDuty().getName());
        else
            request.setAttribute("question_duty", "");
        request.setAttribute("question", q);
        return mapping.findForward("question_detail");
    }

    public ActionForward queryQuestionPrepare(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        List sortList = new LinkedList();
        List hardList = new LinkedList();
        List stationList = new LinkedList();
        List dutyList = new LinkedList();
        try
        {
            sortList = question.queryQuestionSort();
            hardList = question.queryQuestionHard();
            stationList = group.getGroupList("g", "");
            dutyList = group.getGroupList("z", "");
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("sortList", sortList);
        request.setAttribute("hardList", hardList);
        request.setAttribute("stationList", stationList);
        request.setAttribute("dutyList", dutyList);
        return mapping.findForward("question_query");
    }

    public ActionForward addExamPrepare(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        List orgList = null;
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String org_id = userSession.getOrgId();
            Organize o = organize.findOrganizeById(org_id);
            orgList = organize.findAllChildOrganize(o);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("organize", orgList);
        return mapping.findForward("paper_create");
    }

    public ActionForward queryQuestionForPaper(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String organize_id = "";
        String user_id = "";
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            organize_id = userSession.getManageOrgId();
            user_id = userSession.getId();
        }
        catch(NullPointerException e)
        {
            return mapping.findForward("session_dead");
        }
        Integer exam_access = new Integer(request.getParameter("exam_access"));
        Integer exam_type = new Integer(request.getParameter("exam_type"));
        Integer period = new Integer(request.getParameter("exam_time"));
        String name = request.getParameter("exam_name");
        String start_time = request.getParameter("start_time");
        String end_time = request.getParameter("end_time");
        String start_hour = request.getParameter("start_hour");
        String start_minute = request.getParameter("start_minute");
        String end_hour = request.getParameter("end_hour");
        String end_minute = request.getParameter("end_minute");
        Paper p = new Paper();
        p.setName(name);
        p.setType(exam_access);
        p.setSort(exam_type);
        p.setPeriod(period);
        p.setDeleted(new Integer(1));
        p.setOrganizeId(organize_id);
        p.setCreater(user_id);
        p.setScore(new Integer(0));
        p.setState(new Integer(2));
        p.setStartTime(start_time + " " + start_hour + ":" + start_minute);
        p.setEndTime(end_time + " " + end_hour + ":" + end_minute);
        try
        {
            p = question.createPaper(p);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.getSession().setAttribute("paper", p);
        return mapping.findForward("questionCondition");
    }

    public ActionForward paperQuestionList(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String sort_id = request.getParameter("sort_id");
        String type = request.getParameter("type");
        List sortList = new LinkedList();
        List sort = null;
        try
        {
            if(sort_id == null || "".equals(sort_id))
            {
                sort_id = "";
                sortList = question.queryQuestionSort();
            } else
            {
                sortList.add(question.findQuestionSortById(sort_id));
            }
            sort = question.queryQuestionSort();
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        String hard_id = request.getParameter("hard_id");
        if(hard_id == null)
            hard_id = "";
        String course_id = request.getParameter("course_id");
        if(course_id == null)
            course_id = "";
        String station_id = request.getParameter("station_id");
        if(station_id == null)
            station_id = "";
        String duty_id = request.getParameter("duty_id");
        if(duty_id == null)
            duty_id = "";
        List list = null;
        try
        {
            list = question.queryQuestion(sort_id, hard_id, course_id, "", station_id, duty_id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("sort", sort);
        request.setAttribute("sortList", sortList);
        request.setAttribute("list", list);
        request.getSession().setAttribute("type", type);
        return mapping.findForward("paper_question_select");
    }

    public ActionForward queryPaperQuestionPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        List sortList = new LinkedList();
        List hardList = new LinkedList();
        List stationList = new LinkedList();
        List dutyList = new LinkedList();
        try
        {
            sortList = question.queryQuestionSort();
            hardList = question.queryQuestionHard();
            stationList = group.getGroupList("g", "");
            dutyList = group.getGroupList("z", "");
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("sortList", sortList);
        request.setAttribute("hardList", hardList);
        request.setAttribute("stationList", stationList);
        request.setAttribute("dutyList", dutyList);
        return mapping.findForward("paper_question_condition");
    }

    public ActionForward addQuestionToPaper(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String paperId = request.getParameter("paperId");
        String id = request.getParameter("id");
        if(!"".equals(id))
        {
            String question_id[] = id.split(";");
            try
            {
                for(int i = 0; i < question_id.length; i++)
                    question.questionToPaperByManual(question_id[i], paperId);

            }
            catch(BusinessException e)
            {
                e.printStackTrace();
                request.setAttribute("exception", e);
                return mapping.findForward("failure");
            }
        }
        return mapping.findForward("questionCondition");
    }

    public ActionForward setPaperScore(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        String paperId = request.getParameter("paperId");
        List sort = null;
        Paper p = null;
        if(!"".equals(id))
        {
            String question_id[] = id.split(";");
            try
            {
                for(int i = 0; i < question_id.length; i++)
                    question.questionToPaperByManual(question_id[i], paperId);

            }
            catch(BusinessException e)
            {
                e.printStackTrace();
                request.setAttribute("exception", e);
                return mapping.findForward("failure");
            }
        }
        try
        {
            p = question.findPaperById(paperId);
            sort = question.queryPaperSort(paperId);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("paper", p);
        request.setAttribute("list", sort);
        return mapping.findForward("paper_score");
    }

    public ActionForward assignScore(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String paperId = request.getParameter("paperId");
        String score = request.getParameter("score");
        String sortId = request.getParameter("sortId");
        String sort_score[] = score.split(",");
        String sort_id[] = sortId.split(",");
        int total_score = Integer.parseInt(request.getParameter("total"));
        int count = 0;
        String map = "";
        List list = null;
        Paper p = null;
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String user_id = userSession.getUserId();
            String organize_id = userSession.getManageOrgId();
            Organize org = organize.findOrganizeById(organize_id);
            String org_url = org.getUrl();
            p = question.findPaperById(paperId);
            for(int i = 0; i < sort_id.length; i++)
            {
                count = question.sortTotal(paperId, sort_id[i]);
                question.assignScore(paperId, sort_id[i], total_score, Float.parseFloat(sort_score[i]) / (float)count);
                if(p.getSort().intValue() == 1)
                    map = "exam_course";
                else
                if(p.getSort().intValue() == 2)
                {
                    map = "exam_train";
                    list = train.findAdminTrain(user_id);
                } else
                if(p.getSort().intValue() == 3)
                {
                    map = "exam_group";
                    list = group.getGroupList("g", organize_id);
                    request.setAttribute("type", "g");
                } else
                if(p.getSort().intValue() == 4)
                {
                    map = "exam_group";
                    list = group.getGroupList("z", organize_id);
                    request.setAttribute("type", "z");
                } else
                if(p.getSort().intValue() == 7)
                {
                    map = "exam_group";
                    list = group.getGroupList("u", organize_id);
                    request.setAttribute("type", "u");
                } else
                if(p.getSort().intValue() == 5)
                {
                    request.setAttribute("paper", p);
                    if(request.getSession().getAttribute("type") != null && request.getSession().getAttribute("type").toString().equals("2"))
                    {
                        map = "exam_publish_complete";
                        request.removeAttribute("type");
                    } else
                    {
                        map = "exam_certificate";
                        list = certificate.getCertificateList(org_url);
                    }
                } else
                if(p.getSort().intValue() == 6)
                {
                    list = organize.findAllChildOrganize(org);
                    map = "exam_organize";
                    String str = organize.getOrgCkBTree(org, "tree");
                    request.setAttribute("str", str);
                } else
                if(p.getSort().intValue() == 8)
                {
                    request.setAttribute("paper", p);
                    map = "exam_student";
                    list = organize.findAllUser(org, 'a');
                }
            }

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("list", list);
        request.setAttribute("paper", p);
        return mapping.findForward(map);
    }

    public ActionForward assignCourse(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String paper_id = request.getParameter("paperId");
        String courseList = request.getParameter("courseList");
        String course_id[] = courseList.split("&");
        Paper p = null;
        try
        {
            for(int i = 0; i < course_id.length; i++)
                question.assignCourse(paper_id, course_id[i]);

            p = question.findPaperById(paper_id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("paper", p);
        return mapping.findForward("exam_publish_complete");
    }

    public ActionForward assignGroup(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String paper_id = request.getParameter("paperId");
        String groupList = request.getParameter("groupList");
        String group_id[] = groupList.split("&");
        Paper p = null;
        try
        {
            p = question.findPaperById(paper_id);
            for(int i = 0; i < group_id.length; i++)
                question.assignGroup(paper_id, group_id[i]);

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("paper", p);
        return mapping.findForward("exam_publish_complete");
    }

    public ActionForward assignTrain(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String paper_id = request.getParameter("paperId");
        String trainList = request.getParameter("trainList");
        String train_id[] = trainList.split("&");
        Paper p = null;
        try
        {
            p = question.findPaperById(paper_id);
            for(int i = 0; i < train_id.length; i++)
                question.assignTrain(paper_id, train_id[i]);

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("paper", p);
        return mapping.findForward("exam_publish_complete");
    }

    public ActionForward assignStudent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String paper_id = request.getParameter("paperId");
        String userList = request.getParameter("userList");
        String user_id[] = userList.split("&");
        Paper p = null;
        try
        {
            p = question.findPaperById(paper_id);
            for(int i = 0; i < user_id.length; i++)
                question.assignStudent(paper_id, user_id[i]);

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("paper", p);
        return mapping.findForward("exam_publish_complete");
    }

    public ActionForward assignCertificate(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String paper_id = request.getParameter("paperId");
        String certificateList = request.getParameter("certificateList");
        String certificate_id[] = certificateList.split("&");
        Paper p = null;
        try
        {
            p = question.findPaperById(paper_id);
            for(int i = 0; i < certificate_id.length; i++)
                question.assignCertificate(paper_id, certificate_id[i]);

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("paper", p);
        return mapping.findForward("exam_publish_complete");
    }

    public ActionForward assignOrganize(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String paper_id = request.getParameter("paperId");
        String orgSelect = request.getParameter("organizeSel");
        String organize_id[] = orgSelect.split("&");
        Paper p = null;
        try
        {
            p = question.findPaperById(paper_id);
            for(int i = 0; i < organize_id.length; i++)
                question.assignOrganize(paper_id, organize_id[i]);

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("paper", p);
        return mapping.findForward("exam_publish_complete");
    }

    public ActionForward previewPaper(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String paper_id = request.getParameter("paperId");
        Paper p = null;
        List list = null;
        try
        {
            p = question.findPaperById(paper_id);
            list = question.queryPaperQuestion(paper_id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("paper", p);
        request.setAttribute("list", list);
        return mapping.findForward("paper_preview");
    }

    public ActionForward examManage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        int currentPage = 0;
        int pageSize = 10;
        int state = 0;
        String page = request.getParameter("page");
        String row = request.getParameter("row");
        String strState = request.getParameter("state");
        if(strState != null)
            state = Integer.parseInt(strState);
        List list = null;
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String user_id = userSession.getId();
            if(page == null || "".equals(page))
                currentPage = 1;
            else
                currentPage = Integer.parseInt(page);
            pageInfo = question.selectPaper(user_id, row, state, pageSize);
            pageInfo.setPage(currentPage);
            pageInfo.setRow(row);
            request.getSession().setAttribute("pageInfo", pageInfo);
            list = question.findPageList(pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("state", (new StringBuffer(String.valueOf(state))).toString());
        request.setAttribute("list", list);
        return mapping.findForward("exam_list");
    }

    public ActionForward removeExam(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        String paper_id[] = id.split(";");
        try
        {
            for(int i = 0; i < paper_id.length; i++)
            {
                if(question.findPaperById(paper_id[i]).getSort().intValue() == 5)
                {
                    Certificate cert = question.findPaperCertificate(paper_id[i]);
                    if(cert != null)
                    {
                        cert.setState(new Integer(2));
                        certificate.save(cert);
                    }
                }
                question.removePaper(paper_id[i]);
            }

        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        return mapping.findForward("examList");
    }

    public ActionForward examScore(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        int currentPage = 0;
        int pageSize = 10;
        String page = request.getParameter("page");
        String row = request.getParameter("row");
        String strState = request.getParameter("state");
        int state = Integer.parseInt(strState);
        String map = "";
        if(state == 1)
            map = "exam_result";
        else
        if(state == 2)
            map = "exam_mark";
        List list = null;
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String user_id = userSession.getId();
            if(page == null || "".equals(page))
                currentPage = 1;
            else
                currentPage = Integer.parseInt(page);
            pageInfo = question.examScore(user_id, row, pageSize);
            pageInfo.setPage(currentPage);
            pageInfo.setRow(row);
            request.getSession().setAttribute("pageInfo", pageInfo);
            list = question.findPageList(pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("list", list);
        return mapping.findForward(map);
    }

    public ActionForward examDetail(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        Paper p = null;
        try
        {
            p = question.findPaperById(id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("paper", p);
        return mapping.findForward("exam_detail");
    }

    public ActionForward examMark(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        List list = null;
        Paper p = null;
        try
        {
            p = question.findPaperById(id);
            list = question.queryExamStudent(id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("paper", p);
        request.setAttribute("list", list);
        return mapping.findForward("exam_student_list");
    }

    public ActionForward studentScore(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        String id = request.getParameter("id");
        List list = null;
        Paper p = null;
        try
        {
            p = question.findPaperById(id);
            list = question.queryExamUserScore(id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        request.setAttribute("paper", p);
        request.setAttribute("list", list);
        return mapping.findForward("student_score_list");
    }

    public ActionForward myScore(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        List list = null;
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String user_id = userSession.getId();
            list = question.queryMyScore(user_id);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("list", list);
        return mapping.findForward("my_score");
    }

    public ActionForward examCompleted(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException
    {
        int currentPage = 0;
        int pageSize = 3;
        String page = request.getParameter("page");
        String row = request.getParameter("row");
        List list = null;
        try
        {
            UserSession userSession = (UserSession)request.getSession().getAttribute("userSession");
            String org_id = userSession.getManageOrgId();
            String user_id = userSession.getId();
            if(page == null || "".equals(page))
                currentPage = 1;
            else
                currentPage = Integer.parseInt(page);
            pageInfo = question.examCompleted(user_id, org_id, row, pageSize);
            pageInfo.setPage(currentPage);
            pageInfo.setRow(row);
            request.getSession().setAttribute("pageInfo", pageInfo);
            list = question.findPageList(pageInfo);
        }
        catch(BusinessException e)
        {
            e.printStackTrace();
            request.setAttribute("exception", e);
            return mapping.findForward("failure");
        }
        catch(NullPointerException ne)
        {
            return mapping.findForward("session_dead");
        }
        request.setAttribute("list", list);
        return mapping.findForward("exam_complete");
    }

    private static Logger logger;
    private DynaActionForm daf;
    private Pagination pageInfo;
    static Class class$0; /* synthetic field */

    static 
    {
        logger = Logger.getLogger(com.iphaeton.lms.action.exam.QuestionAction.class.getName());
    }
}
